package com.roger.xcontact;

import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;

public class ResultActivity extends Activity {

	private XContactApplication xcontactApplication;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_result);

		xcontactApplication = (XContactApplication) getApplication();
		String userName = xcontactApplication.getUserName();
		String pasword = xcontactApplication.getPasword();

		EditText userNameValue = (EditText) this
				.findViewById(R.id.userNameValue);
		userNameValue.setText(userName);

		EditText userPaswordValue = (EditText) this
				.findViewById(R.id.userPasswordValue);
		userPaswordValue.setText(pasword);

		/**
		 * Network Type List View
		 */

		ConnectivityManager manager = (ConnectivityManager) this
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo networkInfo = manager.getActiveNetworkInfo();
		String subTypeName = networkInfo.getSubtypeName();
		String typeName = networkInfo.getTypeName();

		ListView networkListView = (ListView) findViewById(R.id.network_listview);
		ArrayAdapter adapter = new ArrayAdapter<String>(this,
				R.layout.list_item, new String[] { "typeName=" + typeName,
						"subTypeName=" + subTypeName });
		networkListView.setAdapter(adapter);

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.result, menu);
		return true;
	}

}
